<template>
	<!-- 申请退款 -->
	<view class="form-container">
		<nt-order-detail :orderInfo="commonForm.orderInfo"></nt-order-detail>
		<nt-card label="上传广告图">
			<view class="form-item vertical">
				<!-- <view class="form-item__label">修改内容：</view> -->
				<view class="form-item__content">
					<u--textarea v-model="formData.gg_remarks" maxlength="-1" :confirmType="null"></u--textarea>
				</view>
			</view>
			<view class="form-item vertical">
				<view class="form-item__label">上传图片：</view>
				<view class="form-item__content">
					<nt-upload @success="formData.gg_img = $event" :maxCount="1"></nt-upload>
				</view>
			</view>
			<nt-button text="提交广告图['转回客服']" @tap="submit"></nt-button>
		</nt-card>
	</view>
</template>

<script>
	import {
		sendPostGG
	} from "@/api"
	export default {
		data() {
			return {
				formData: {
					gg_remarks: "",
					gg_img: []
				},
				loading: false
			}
		},
		inject: ["commonForm"],
		methods: {
			// 提交转单申请
			submit() {
				const gg_img = this.formData.gg_img.map(item => item.url)
				if (gg_img.length === 0 && this.formData.gg_remarks.length === 0) {
					return this.toast("请输入备注")
				}
				if (this.loading) return
				this.loading = true
				sendPostGG({
					realorder_id: this.commonForm.options.id,
					gg_remarks: this.formData.gg_remarks,
					gg_img
				}).then(res => {
					const {
						code
					} = res;
					if (code === 1) {
						this.toast("广告图已提交")
						setTimeout(() => {
							this.back()
							uni.$emit('changeList')
						}, 1000)
					}
				}).finally(() => {
					this.loading = false
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "./style.scss";

	/deep/ .button-container {
		margin-top: 60rpx;
	}
</style>